import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'dva'
import { Row, Col, Card ,DatePicker,Table,Tag} from 'antd'
import { color } from 'utils'
import List from './List'
import dashboard from '../../models/dashboard';

const Message = ({ location, dispatch, message, loading }) => {
    const { list,pagination,list1,pagination1 } = message
    // console.log(pagination)
    const listProps = {
        list,
        pagination,
        list1,
        pagination1,
        readOne(params){
            dispatch({
                type:"message/readOneMessage",
                payload:{
                    ...params
                }
            })
        },
        readAll(){
            dispatch({
                type:"message/readAllMessage"
            })
        },
        getAllMessage(){
            dispatch({
                type:"message/getAllMessage"
            })
        },
        getNewMessage(){
            dispatch({
                type:"message/getNewMessage"
            })  
        },
        onPageChange(page) {
			const { query, pathname } = location
			dispatch({
				type: 'message/getNewMessage',
				payload: {
					page: page.current,
					pageSize: page.pageSize,
				}
			})
        },
        onPageChange1(page) {
			const { query, pathname } = location
			dispatch({
				type: 'message/getAllMessage',
				payload: {
					page: page.current,
					pageSize: page.pageSize,
				}
			})
		},
    }
    return(
        <div>
            <List {...listProps}/>
        </div>
    )
}

export default connect(({ message, loading }) => ({message,loading}))(Message)